//
//  UIViewController+HDAlwaysQuestionController.m
//  app
//
//  Created by D on 15/7/16.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HDAlwaysQuestionController.h"

@interface HDAlwaysQuestionController ()

@property (nonatomic,strong) UIWebView * alwaysWeb;
@property (nonatomic,strong) SNUniteUrl * uniteUrl;

@end

@implementation HDAlwaysQuestionController

-(void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"常见问题";
    self.navigationController.navigationBar.hidden = NO;
    self.uniteUrl = [SNUniteUrl shareUniteUrl];
    self.automaticallyAdjustsScrollViewInsets = NO;

    self.alwaysWeb = [[UIWebView alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT fy:UB_TOP oy:64], [self.ubo fw:UB_WIDTH fh:UB_HEIGHT oh:-self.navigationAndStatusBarHeight])];;
    self.alwaysWeb.delegate = self;
    self.alwaysWeb.scrollView.delegate = self;
    [self.view addSubview:self.alwaysWeb];
   
    [self.alwaysWeb.nothingRefreshView showLoadingMsg:nil errorMsg:@"加载失败,点击重试"];
    
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    self.navigationController.navigationBar.hidden = NO;
    self.alwaysWeb.frame = CGRectOf([self.ubo fx:UB_LEFT fy:UB_TOP oy:self.navigationAndStatusBarHeight], [self.ubo fw:UB_WIDTH fh:UB_HEIGHT oh:-self.navigationAndStatusBarHeight]);
     [self.alwaysWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.uniteUrl.static_qaUrl]]];
}

#pragma mark 从新加载页面
- (void)refreshData{
    [self.alwaysWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.uniteUrl.static_qaUrl]]];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [self.alwaysWeb.scrollView endRefreshingAll];
    [self.alwaysWeb.nothingRefreshView remove];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    [self.alwaysWeb.nothingRefreshView activeStop];
}

-(void)didReceiveMemoryWarning
{
    
}

@end
